/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = __module_make_all_value .c                         */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/04 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <protobuf-c/protobuf-c.h>

#include "frcomm.h"
#include "frmem.h"
#include "frame.h"
#include "client.pb.h"
#include "frsutl.h"
#include "frcmd_server_l7.h"
#include "frame_params.h"
#include "apmtest_cunit.h"


static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

int __module_make_all_value(const char *p_path_bin, int i_proto, char **pp_all_value);

void case1(void)
{
    const char *p_path_bin = "http";
    int i_proto = 80;
    char *p_all_value = NULL;
    int i_ret = 0;

    i_ret = __module_make_all_value(p_path_bin, i_proto, &p_all_value);

    CU_ASSERT_EQUAL(i_ret, FR_SUCC);
    CU_ASSERT_STRING_EQUAL(p_all_value, "[80] http");

    frfree(p_all_value);
    return;

}

void case2(void)
{
    const char *p_path_bin = NULL;
    int i_proto = 80;
    char *p_all_value = NULL;
    int i_ret = 0;

    i_ret = __module_make_all_value(p_path_bin, i_proto, &p_all_value);

    CU_ASSERT_EQUAL(i_ret, FR_FAIL);

    return;

}


int add_suite()
{
    CU_pSuite pSuite = NULL;

    pSuite = CU_add_suite("__module_make_all_value 测试", __suite_init, __suite_cleanup);

    if (NULL == pSuite)
    {
        return 1;
    }


    //增加测试用例
    CU_add_test(pSuite, "case1", case1);
    CU_add_test(pSuite, "case2", case2);
//    CU_add_test(pSuite, "case3", case3);
//    CU_add_test(pSuite, "case4", case4);
//    CU_add_test(pSuite, "case5", case5);

    return 0;

}

int main(int argc, char **argv)
{
    fr_slab_init(52428800, "test");
    run_cunit(add_suite);
    fr_slab_destroy();

    return 0;
}
